<cfoutput>





<cfparam name="FirstName" default="">
<cfparam name="LastName" default="">
<cfparam name="Password" default="">
<cfparam name="Username" default="">
<cfparam name="companyname" default="">
<cfparam name="Address" default="">
<cfparam name="City" default="">
<cfparam name="State" default="">
<cfparam name="ZipCode" default="">
<cfparam name="email" default="">
<cfparam name="cell" default="">
<cfparam name="MainPhone" default="">
<cfparam name="fax" default="">







<cfif isdefined("form.new")>

<cflock timeout=20 scope="Session" type="Exclusive">
<cfset structdelete(SESSION, "DODAAC")> 
</cflock>


 
<CFQUERY NAME="getcount" DATASOURCE="#dsn#">
select *
from tblcounter
where id = 1
</CFQUERY>

<cfset NEWCUST = #getcount.DonorCounter# + 1>

<CFSET DODAAC = #NEWCUST#>



<cfset session.NEW = "Yes">
<cfset session.DODAAC = "#DODAAC#">

<CFQUERY DATASOURCE="#Datasource#">
UPDATE tblcounter
SET DonorCounter = #NEWCUST#
where id = 1
</CFQUERY>





<cfquery datasource="#dsn#">
INSERT INTO tblprofiles(FirstName, LastName, username, password, companyname, DODAAC, PIN)
VALUES('#FirstName#',
'#LastName#',
'#Username#',
'#password#',
'#companyname#',
#DODAAC#,
#DODAAC#
)
</cfquery>

<CFQUERY NAME="getprofile" DATASOURCE="#dsn#">
select *
from tblprofiles
where DODAAC = 0
</CFQUERY>

<cflocation url="index.cfm?tab=1&DODAAC=#session.DODAAC#">


<cflock timeout=20 scope="Session" type="Exclusive">
<cfset structdelete(SESSION, "DODAAC")> 
</cflock>

<cfelse>

<cflock timeout=20 scope="Session" type="Exclusive">
<cfset structdelete(SESSION, "new")> 
</cflock>

<!---<cfdump var="#SESSION#">
<cfdump var="#FORM#">--->

<CFQUERY NAME="getprofile" DATASOURCE="#dsn#">
select *
from tblprofiles
where <cfif isdefined("session.DODAAC")>DODAAC = #session.DODAAC#<cfelse>DODAAC = #DODAAC#</cfif>
</CFQUERY>


<cfif #form.tab# is 1>
<cfquery datasource="#dsn#">
update tblprofiles
set FirstName = '#FirstName#', 
LastName = '#LastName#', 
username = '#Username#', 
password = '#password#', 
companyname = '#companyname#'

where <cfif isdefined("session.DODAAC")>DODAAC = #session.DODAAC#<cfelse>DODAAC = #DODAAC#</cfif>


</cfquery>
</cfif>

<cfif #form.tab# is 2>

<cfquery datasource="#dsn#">
update tblprofiles
set 
Address = '#Address#',
City = '#City#',
State = '#State#',
ZipCode = '#ZipCode#'

where <cfif isdefined("session.DODAAC")>DODAAC = #session.DODAAC#<cfelse>DODAAC = #DODAAC#</cfif>


</cfquery>
</cfif>



<cfif #form.tab# is 3>

<cfquery datasource="#dsn#">
update tblprofiles
set
email = '#email#',
cell = '#cell#',
MainPhone = '#MainPhone#',
fax = '#fax#'

where <cfif isdefined("session.DODAAC")>DODAAC = #session.DODAAC#<cfelse>DODAAC = #DODAAC#</cfif>


</cfquery>
</cfif>




<cfif #form.tab# is 1>
<cflocation url="index.cfm?tab=1&DODAAC=#getprofile.DODAAC#">
</cfif>

<cfif #form.tab# is 2>
<cflocation url="index.cfm?tab=2&DODAAC=#getprofile.DODAAC#">
</cfif>

<cfif #form.tab# is 3>
<cflocation url="index.cfm?tab=3&DODAAC=#getprofile.DODAAC#">
</cfif>

<cfif #form.tab# is 4>
<cflocation url="index.cfm?tab=4&DODAAC=#getprofile.DODAAC#">
</cfif>


</cfif>


</cfoutput>